package com.tencent.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tencent.entity.CheckGroup;
import com.tencent.entity.Checkitem;
import com.tencent.entity.Pagination;
import com.tencent.entity.Result;
import com.tencent.mapper.CheckGroupMapper;
import com.tencent.service.CheckGroupService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @author: Fame
 * @date: 2022-08-11 15:51
 * @description:
 */
@Service
public class CheckGroupServiceImpl implements CheckGroupService {

    @Autowired
    private CheckGroupMapper checkGroupMapper;

    @Override
    public PageInfo<CheckGroup> getAll(Pagination pagination) {
        PageHelper.startPage(pagination.getCurrentPage(),pagination.getPageSize());
        List<CheckGroup> list = checkGroupMapper.findAll(pagination.getQueryString());
        return new PageInfo<>(list);
    }

    @Override
    public int insert(@RequestBody CheckGroup checkGroup) {
        return checkGroupMapper.insert(checkGroup);
    }

    @Override
    public int delHandle(String id) {
        return checkGroupMapper.deleteByCode(id);
    }

    @Override
    public CheckGroup findById(Integer id) {
        return checkGroupMapper.findById(id);
    }

    @Override
    public int updateBean(CheckGroup checkGroup) {
        return checkGroupMapper.updateById(checkGroup);
    }

    @Override
    public List<Checkitem> findChecks(Integer id) {
        return checkGroupMapper.findChecks(id);
    }

    @Override
    public List<Checkitem> findAddChecks(){
        return checkGroupMapper.findAddChecks();
    }

    @Override
    public int insertChecks(@Param("groupId") Integer groupId,@Param("itemId") Integer itemId) {
        return checkGroupMapper.insertChecks(groupId,itemId);
    }
}
